#pragma once

#include "NFServerComm/NFServerCommon/NFIDescStore.h"
#include "NFServerComm/NFServerCommon/NFIDescTemplate.h"
#include "NFLogicCommon/NFDescStoreMacrosDefine.h"
#include "NFLogicCommon/NFDescStoreTypeDefines.h"
#include "E_Skin.nanopb.h"
#ifndef MAX_SKIN_SKIN_NUM
#define MAX_SKIN_SKIN_NUM 40
#endif

struct SkinSkinHeroIdDefaultSkin
{
	SkinSkinHeroIdDefaultSkin()
	{
		if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode()) {
			CreateInit();
		}
		else {
			ResumeInit();
		}
	}
	int CreateInit()
	{
		hero_id=0;
		default_skin=0;
		return 0;
	}
	int ResumeInit()
	{
		return 0;
	}
	int64_t hero_id;
	int64_t default_skin;
	bool operator==(const SkinSkinHeroIdDefaultSkin& data) const
	{
		 return hero_id== data.hero_id && default_skin== data.default_skin;
	}
	std::string ToString() const
	{
		std::stringstream ios;
		ios << hero_id;
		ios << ",";
		ios << default_skin;
		return ios.str();
	}
};

namespace std
{
	template<>
	struct hash<SkinSkinHeroIdDefaultSkin>
	{
		size_t operator()(const SkinSkinHeroIdDefaultSkin& data) const
		{
			return NFHash::hash_combine(data.hero_id,data.default_skin);
		}
	};
}


class SkinSkinDesc : public NFI_DESC_TEMPLATE_MACRO(SkinSkinDesc, E_SkinSkin, EOT_CONST_SKIN_SKIN_DESC_ID, MAX_SKIN_SKIN_NUM)
public:
	SkinSkinDesc();
	virtual ~SkinSkinDesc();
	int CreateInit();
	int ResumeInit();
public:
	int Load(NFResDb *pDB) override;
	int LoadDB(NFResDb *pDB) override;
	int CheckWhenAllDataLoaded() override;
	std::vector<const E_SkinSkin*> GetDescByHeroIdDefaultSkin(int64_t heroId, int64_t defaultSkin);
private:
	NFShmHashMultiMap<SkinSkinHeroIdDefaultSkin, uint64_t, MAX_SKIN_SKIN_NUM> m_heroIdDefaultSkinComIndexMap;
};
